package com.config;

import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.filter.AccessControlAllowFilter;
import com.intercepter.CheckSessionInterceptor;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;


@Configuration
public class MywebConfig implements WebMvcConfigurer {
    @Bean
    public FilterRegistrationBean filterRegister(){
        FilterRegistrationBean frBean = new FilterRegistrationBean();
        frBean.setFilter(new AccessControlAllowFilter());
        frBean.addUrlPatterns("/*");
        return frBean;
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加MyInterceptor到注册机里面，该拦截器拦截所有的请求，排除掉/user/*的请求
        registry.addInterceptor(new CheckSessionInterceptor()).addPathPatterns("/**")
                .excludePathPatterns("/user/**");
    }
}
